 package
{
	import flash.display.Bitmap;
	import flash.utils.Dictionary;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;

	public class Assets
	{
		[Embed(source="../res/graphics/bgWelcome.jpg")]
		public static const BgWelcome:Class;
		
		[Embed(source="../res/graphics/bgLayer1.jpg")]
		public static const BgLayer1:Class;
		
		private static var gameTextures:Dictionary = new Dictionary(); 
		public static var gameTextureAtlas:TextureAtlas;
		
		[Embed(source="../res/graphics/mySpritesheet.png")]
		public static const AtlasTextureGame:Class;
		
		[Embed(source="../res/graphics/mySpritesheet.xml", mimeType="application/octet-stream")]
		public static const AtlasXLMGame:Class;
		
		public static function getTextureAtlas():TextureAtlas
		{
			if(gameTextureAtlas == null)
			{
				var texture:Texture = getTexture("AtlasTextureGame");
				var xml:XML = new XML(new AtlasXLMGame());
				
				gameTextureAtlas = new TextureAtlas(texture, xml);
			}
			return gameTextureAtlas;
		}
		
		public static function getTexture(name:String):Texture
		{
			if(gameTextures[name] == undefined)
			{
				var bitmap:Bitmap = new Assets[name]();
				gameTextures[name] = Texture.fromBitmap(bitmap);
			}
			return gameTextures[name];
		}
	}
}